<?php

namespace app\site\controller\site;

use app\common\exception\MiException;
use app\Request;
use app\site\controller\AController;
use app\site\controller\traits\CurdTrait;
use app\site\service\site\UserAddressService;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;


class UserAddressController extends AController
{

    /**
     * @throws DbException
     */
    public function index(){
        return $this->reqSer->setService(UserAddressService::instance())->setPaginate()->getResponse();
    }

    /**
     * @throws MiException
     */
    public function add(){
        return $this->reqSer->setService(UserAddressService::instance())->add()->getResponse();
    }

    /**
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws MiException
     */
    public function edit(Request $request){
        if($request->isPost()){
            return $this->reqSer->setService(UserAddressService::instance())->edit()->getResponse();
        }else{
            return $this->reqSer->setService(UserAddressService::instance())->setFind()->getResponse();
        }
    }

    /**
     * @throws DataNotFoundException
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws MiException
     */
    public function del(){
        return $this->reqSer->setService(UserAddressService::instance())->delete()->getResponse();
    }
}
